package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper extends BaseMapper<Setmeal> {

    @Insert("insert into t_setmeal_checkgroup values(#{id},#{checkgroupId})")
    void addSetmealAndGroupInfo(@Param("id") Integer id, @Param("checkgroupId") Integer checkgroupId);

    @Select("select name,age,remark,img,sex from t_setmeal where id = #{id}")
    SetmealVO findSetmealVOPyId(@Param("id") String id);

    @Select("SELECT ch.ID,ch.`NAME`,ch.remark\n" +
            "from t_setmeal_checkgroup sc \n" +
            "INNER JOIN t_checkgroup ch\n" +
            "on sc.CHECKGROUP_ID = ch.ID\n" +
            "WHERE sc.SETMEAL_ID = #{id}")
    List<Map> findCheckGroupByIds(@Param("id") String id);

    @Select("SELECT ch.ID,ch.`NAME`\n" +
            "from t_checkgroup_checkitem cc \n" +
            "INNER JOIN t_checkitem ch\n" +
            "on cc.CHECKITEM_ID = ch.ID\n" +
            "WHERE cc.CHECKGROUP_ID = #{id}")
    List<Map> findCheckItemByIds(@Param("id") Object id);
}